<template>
    <div>
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
          <el-col :span="12" >
            <el-form-item label="合同编号" prop="htHtcode">
              <el-input v-model="form.htHtcode" placeholder="请输入合同编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="产地" prop="htChandi">
              <el-input v-model="form.htChandi" placeholder="请输入产地" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货主" prop="htHzid">
              <el-input v-model="form.htHzid" placeholder="请选择货主" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供货商" prop="htGhsid">
              <el-input v-model="form.htGhsid" placeholder="请选择供货商" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="htRemark">
              <el-input v-model="form.htRemark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-form>
       
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </div>
</template>

<script>
export default {
  data() {
    return {
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  methods: {
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.htId != null) {
            updateHetong(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addHetong(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    // 取消按钮
    cancel() {
      //this.open = false;
      //this.reset();
    },
  }
} 
</script>